home *** CD-ROM | disk | FTP | other *** search
/ Software Vault: The Gold Collection / Software Vault - The Gold Collection (American Databankers) (1993).ISO / cdr01 / halcn305.zip / GSDMO_20.PAS < prev    next >
Pascal/Delphi Source File  |  1993-05-02  |  4KB  |  147 lines

  1. program GSDMO_20;
  2. {------------------------------------------------------------------------------
  3.                               DBase Reindexing
  4.  
  5.        Copyright (c)  Richard F. Griffin
  6.  
  7.        20 January 1993
  8.  
  9.        102 Molded Stone Pl
  10.        Warner Robins, GA  31088
  11.  
  12.        -------------------------------------------------------------
  13.        Unit to demonstrate Reindex. The indexes are first created and
  14.        listed.  The indexes are then reindexed and listed again to
  15.        show the Reindex procedure accurately reindexed all index files
  16.        and assigned and maintained the proper master index order.
  17.  
  18.        New procedures/functions introduced are:
  19.  
  20.                  Reindex
  21.  
  22. -------------------------------------------------------------------------------}
  23.  
  24. uses
  25.    GSOB_Gen,
  26.    GSOBShel,
  27.    {$IFDEF WINDOWS}
  28.       WinCRT,
  29.       WinDOS;
  30.    {$ELSE}
  31.       CRT,
  32.       DOS;
  33.    {$ENDIF}
  34.  
  35. var
  36.    i       : integer;
  37.    j       : integer;
  38.    c       : char;
  39.  
  40.  
  41. procedure ListTheNames;
  42. begin
  43.    SetOrderTo(1);
  44.    i := 0;
  45.    GoTop;
  46.    while (not dEOF) do
  47.    begin
  48.       inc(i);
  49.       if (i mod 23) = 0 then
  50.       begin
  51.          write('Press any key to continue.');
  52.          c := ReadKey;
  53.          writeln;
  54.       end;
  55.       writeln(RecNo:8,'   ',FieldGet('LASTNAME'),i:6);
  56.       Skip(1);
  57.    end;
  58. end;
  59.  
  60. procedure ListTheDates;
  61. begin
  62.    SetOrderTo(2);                      {Now change to the GSDMO24B index}
  63.    i := 0;
  64.    GoTop;
  65.    while (not dEOF) do
  66.    begin
  67.       inc(i);
  68.       if (i mod 23) = 0 then
  69.       begin
  70.          write('Press any key to continue.');
  71.          c := ReadKey;
  72.          writeln;
  73.       end;
  74.       writeln(RecNo:8,'   ',
  75.               DTOC(DateGet('BIRTHDATE')),i:6);
  76.       Skip(1);
  77.    end;
  78. end;
  79.  
  80.  
  81.                   {----   Main Program ----}
  82.  
  83. begin
  84.    ClrScr;
  85.    SetCenturyOn;            {Needed to show full date}
  86.  
  87.    if not FileExist('GSDMO_20.DBF') then
  88.    begin
  89.       writeln('Creating GSDMO_20.DBF');
  90.       MakeTestData(3,'GSDMO_20', 100, false);      {Make a dBase III file}
  91.       writeln('GSDMO_20.DBF Created');
  92.    end;
  93.  
  94.    Select(1);
  95.    Use('GSDMO_20');
  96.    IndexOn('GSDMO20A','LASTNAME');
  97.    IndexOn('GSDMO20B','BIRTHDATE');
  98.  
  99.             {GSDMO20B should be the master as it was the last IndexOn}
  100.  
  101.    writeln('The master index is ',DBFActive^.IndexMaster^.dfFileName);
  102.    j := 1;
  103.    while DBFActive^.IndexStack[j] <> nil do
  104.    begin
  105.       writeln('Index ',j,' is ',DBFActive^.IndexStack[j]^.dfFileName);
  106.       inc(j);
  107.    end;
  108.    writeln('Press any key to continue.');
  109.    c := ReadKey;
  110.  
  111.    ListTheNames;
  112.  
  113.    writeln('End of File, Now to check date sequence...');
  114.    writeln('Press any key to continue.');
  115.    c := ReadKey;
  116.  
  117.    ListTheDates;
  118.  
  119.    writeln('End of File, Now to Reindex...');
  120.    writeln('Press any key to continue.');
  121.    c := ReadKey;
  122.  
  123.    SetOrderTo(1);             {GSDMO20A should be the master after reindex}
  124.    Reindex;
  125.  
  126.    writeln('Reindexing complete.');
  127.    writeln('The master index is ',DBFActive^.IndexMaster^.dfFileName);
  128.    j := 1;
  129.    while DBFActive^.IndexStack[j] <> nil do
  130.    begin
  131.       writeln('Index ',j,' is ',DBFActive^.IndexStack[j]^.dfFileName);
  132.       inc(j);
  133.    end;
  134.    writeln('Press any key to continue.');
  135.    c := ReadKey;
  136.  
  137.    ListTheNames;
  138.  
  139.    writeln('End of File, Now to check date sequence...');
  140.    writeln('Press any key to continue.');
  141.    c := ReadKey;
  142.  
  143.    ListTheDates;
  144.  
  145.    CloseDataBases;
  146. end.
  147.